from sklearn import datasets
from sklearn.model_selection import  train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score


iris = datasets.load_iris()#导入数据集

X = iris.data#获取特征向量
y = iris.target#获取样本标签


X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.3,random_state=0)

lr = LogisticRegression(random_state=0, max_iter=5000)

lr_model = lr.fit(X_train,y_train)

lr_model_predict = lr_model.predict(X_test)

lr_model_proba = lr_model.predict_proba(X_test).max(axis=1)

accuracy_lr = accuracy_score(y_test,lr_model_predict)